* 06 SEPTEMBER 2005
* REPLICATION FILE FOR "OPENNESS, UNCERTAINTY, AND SOCIAL SPENDING: IMPLICATIONS FOR THE GLOBALIZATION-WELFARE STATE DEBATE"
* by Irfan Nooruddin and Joel Simmons

****************************************************************************************** TABLE 1: SUMMARY STATISTICS************************************************************summ educ_change welfg_change importld importlag exportgdplag exportgdpld tradeld tradelag /*
*/ dumlag dumld pol3lag pol3ld pollag polld educlag educld welflag welfld lngdpcapld lngdpcaplag /*
*/ dependld dependlag  /*
*/ bn_cab_xoka_gd_zslag bn_cab_xoka_gd_zsld log_dt_dod_dect_cdlag log_dt_dod_dect_cdld if oecd==0

****************************************************************************************** TABLE 1: COUNTRIES IN ESTIMATION SAMPLE************************************************************
quietly xi3:  xtpcse educ_change importld*importlag*dumlag educlag educld lngdpcapld lngdpcaplag /*
*/ dependld dependlag dumld exportgdplag exportgdpld /*
*/ bn_cab_xoka_gd_zslag bn_cab_xoka_gd_zsld log_dt_dod_dect_cdlag log_dt_dod_dect_cdld year f1-f215 if oecd==0, paestimates store base_educ
quietly xi3:  xtpcse welfg_change importld*importlag*dumlag welfglag welfgld lngdpcapld lngdpcaplag /*
*/ dependld dependlag dumld exportgdplag exportgdpld /*
*/ bn_cab_xoka_gd_zslag bn_cab_xoka_gd_zsld log_dt_dod_dect_cdlag log_dt_dod_dect_cdld year f1-f215 if oecd==0, paestimates store base_welfg

estimates restore base_educ
tab ctryname if e(sample)
estimates restore base_welfg
tab ctryname if e(sample)


****************************************************************************************** TABLE 2: THE EFFECT OF INCREASING OPENNESS ON WELFARE AND EDUCATION SPENDING************************************************************quietly xi3:  xtpcse educ_change importld*importlag*dumlag educlag educld lngdpcapld lngdpcaplag /*
*/ dependld dependlag dumld exportgdplag exportgdpld /*
*/ bn_cab_xoka_gd_zslag bn_cab_xoka_gd_zsld log_dt_dod_dect_cdlag log_dt_dod_dect_cdld year f1-f215 if oecd==0, paestimates store base_educ
quietly xi3:  xtpcse welfg_change importld*importlag*dumlag welfglag welfgld lngdpcapld lngdpcaplag /*
*/ dependld dependlag dumld exportgdplag exportgdpld /*
*/ bn_cab_xoka_gd_zslag bn_cab_xoka_gd_zsld log_dt_dod_dect_cdlag log_dt_dod_dect_cdld year f1-f215 if oecd==0, paestimates store base_welfg

estimates table base_welfg base_educ base_educ , /*
 */ b(%10.2f) se(%10.2f) p(%10.2f) stats(N ll aic bic) /*
 */ keep(welfglag welfgld educlag educld importld importlag dumlag _IimXim _IimXdu _I1imXdu _IimXimXdu /*
 */  exportgdplag exportgdpld lngdpcapld /*
 */ lngdpcaplag dependld dependlag dumld bn_cab_xoka_gd_zslag bn_cab_xoka_gd_zsld /*
 */ log_dt_dod_dect_cdlag log_dt_dod_dect_cdld year) label

************************************************************
****************************** FIGURE 6: MARGINAL EFFECT GRAPH FOR WELFARE (% TOTAL SPENDING)
************************************************************
estimates restore base_welfg#delimit ;generate MV=((_n-1)/1);replace  MV=. if _n>220;scalar W0 =      0;scalar W1=     1;scalar W2=     0;scalar W3=       1;matrix b=e(b);matrix V=e(V);scalar b1=b[1,1];scalar b2=b[1,2];scalar b3=b[1,3];scalar b4=b[1,4];scalar b5=b[1,5];scalar b6=b[1,6];scalar b7=b[1,7];scalar varb1=V[1,1];scalar varb2=V[2,2];scalar varb3=V[3,3];scalar varb4=V[4,4];scalar varb5=V[5,5];scalar varb6=V[6,6];scalar varb7=V[7,7];scalar covb1b4=V[1,4];scalar covb1b5=V[1,5];scalar covb1b7=V[1,7];scalar covb4b5=V[4,5];scalar covb4b7=V[4,7];scalar covb5b7=V[5,7];scalar list b1 b2 b3 b4 b5 b6 b7 varb1 varb2 varb3 varb4 varb5 varb6 varb7             covb1b4 covb1b5 covb1b7 covb4b5 covb4b7 covb5b7;gen conb0=b1+b4*MV+b5*W0+b7*(MV*W0) if _n<220;gen conb1=b1+b4*MV+b5*W1+b7*(MV*W1) if _n<220;gen conb2=b1+b4*MV+b5*W2+b7*(MV*W2) if _n<220;gen conb3=b1+b4*MV+b5*W3+b7*(MV*W3) if _n<220;gen conse0=sqrt(varb1                + varb4*(MV^2) + varb5*(W0^2) + varb7*(MV^2)*(W0^2)                + 2*MV*covb1b4 + 2*W0*covb1b5 + 2*MV*W0*covb1b7 + 2*MV*W0*covb4b5                + 2*W0*(MV^2)*covb4b7 + 2*(W0^2)*MV*covb5b7) if _n<220;gen conse1=sqrt(varb1                + varb4*(MV^2) + varb5*(W1^2) + varb7*(MV^2)*(W1^2)                + 2*MV*covb1b4 + 2*W1*covb1b5 + 2*MV*W1*covb1b7 + 2*MV*W1*covb4b5                + 2*W1*(MV^2)*covb4b7 + 2*(W1^2)*MV*covb5b7) if _n<220;gen conse2=sqrt(varb1                + varb4*(MV^2) + varb5*(W2^2) + varb7*(MV^2)*(W2^2)                + 2*MV*covb1b4 + 2*W2*covb1b5 + 2*MV*W2*covb1b7 + 2*MV*W2*covb4b5                + 2*W2*(MV^2)*covb4b7 + 2*(W2^2)*MV*covb5b7) if _n<220;gen conse3=sqrt(varb1                + varb4*(MV^2) + varb5*(W3^2) + varb7*(MV^2)*(W3^2)                + 2*MV*covb1b4 + 2*W3*covb1b5 + 2*MV*W3*covb1b7 + 2*MV*W3*covb4b5                + 2*W3*(MV^2)*covb4b7 + 2*(W3^2)*MV*covb5b7) if _n<220;      gen t0=conb0/conse0;gen t1=conb1/conse1;gen t2=conb2/conse2;gen t3=conb3/conse3;gen consb0=conb0;gen consb1=conb1;gen consb2=conb2;gen consb3=conb3;replace consb0 = . if abs(t0)<1.96;replace consb1 = . if abs(t1)<1.96;replace consb2 = . if abs(t2)<1.96;replace consb3 = . if abs(t3)<1.96;generate str1 txt="*";

graph twoway   line conb0  MV,  clcolor(black) clpattern() clwidth(medthick)  /**/        ||  scatter consb0 MV, mlabel(txt) msymbol(i) mlabsize(vsmall) mlabgap(-1.0) mlabposition(11) /**/        ||     line conb1  MV,  clcolor(maroon) clpattern(dash) clwidth(medthick) /* */       ||  scatter consb1 MV,  mlabel(txt) msymbol(i) mlabsize(vsmall) mlabgap(-1.0) mlabposition(11)/*  */      ||     line conb2  MV,  clcolor(none)clpattern(dot) clwidth(medthick) /**/        ||  scatter consb2 MV,  mlabel() msymbol(i) mlabsize(vsmall) mlabgap(-1.0) mlabposition(11) /**/       ||     line conb3  MV,  clcolor(none) clpattern() clwidth() /**/        ||  scatter consb3 MV,  mlabel() msymbol(i) mlabsize(vsmall) mlabgap(-1.0) mlabposition(11)  /**/     graphregion(color(white))  /**/  ytitle(Marginal Effect of Change in Imports,size(3)) xtitle(Level of Import Openness (% GDP)) xlabel() yline(0, lcolor(black)) title("", size(3)) /**/  note(* = significance at 95%, size(2.5)) caption() /**/  title(Marginal effect of increasing imports on welfare spending (% Total Spending), size(2.75)) /*
*/  legend(off)

drop  MV conb0 conb1 conb2 conb3 conse0 conse1 conse2 conse3 t0 t1 t2 t3 consb0 consb1 consb2 consb3 txt

************************************************************
****************************** FIGURE 7: MARGINAL EFFECT GRAPH FOR EDUCATION (% TOTAL SPENDING)
************************************************************
estimates restore base_educ#delimit ;generate MV=((_n-1)/1);replace  MV=. if _n>220;scalar W0 =      0;scalar W1=     1;scalar W2=     0;scalar W3=       1;matrix b=e(b);matrix V=e(V);scalar b1=b[1,1];scalar b2=b[1,2];scalar b3=b[1,3];scalar b4=b[1,4];scalar b5=b[1,5];scalar b6=b[1,6];scalar b7=b[1,7];scalar varb1=V[1,1];scalar varb2=V[2,2];scalar varb3=V[3,3];scalar varb4=V[4,4];scalar varb5=V[5,5];scalar varb6=V[6,6];scalar varb7=V[7,7];scalar covb1b4=V[1,4];scalar covb1b5=V[1,5];scalar covb1b7=V[1,7];scalar covb4b5=V[4,5];scalar covb4b7=V[4,7];scalar covb5b7=V[5,7];scalar list b1 b2 b3 b4 b5 b6 b7 varb1 varb2 varb3 varb4 varb5 varb6 varb7             covb1b4 covb1b5 covb1b7 covb4b5 covb4b7 covb5b7;gen conb0=b1+b4*MV+b5*W0+b7*(MV*W0) if _n<220;gen conb1=b1+b4*MV+b5*W1+b7*(MV*W1) if _n<220;gen conb2=b1+b4*MV+b5*W2+b7*(MV*W2) if _n<220;gen conb3=b1+b4*MV+b5*W3+b7*(MV*W3) if _n<220;gen conse0=sqrt(varb1                + varb4*(MV^2) + varb5*(W0^2) + varb7*(MV^2)*(W0^2)                + 2*MV*covb1b4 + 2*W0*covb1b5 + 2*MV*W0*covb1b7 + 2*MV*W0*covb4b5                + 2*W0*(MV^2)*covb4b7 + 2*(W0^2)*MV*covb5b7) if _n<220;gen conse1=sqrt(varb1                + varb4*(MV^2) + varb5*(W1^2) + varb7*(MV^2)*(W1^2)                + 2*MV*covb1b4 + 2*W1*covb1b5 + 2*MV*W1*covb1b7 + 2*MV*W1*covb4b5                + 2*W1*(MV^2)*covb4b7 + 2*(W1^2)*MV*covb5b7) if _n<220;gen conse2=sqrt(varb1                + varb4*(MV^2) + varb5*(W2^2) + varb7*(MV^2)*(W2^2)                + 2*MV*covb1b4 + 2*W2*covb1b5 + 2*MV*W2*covb1b7 + 2*MV*W2*covb4b5                + 2*W2*(MV^2)*covb4b7 + 2*(W2^2)*MV*covb5b7) if _n<220;gen conse3=sqrt(varb1                + varb4*(MV^2) + varb5*(W3^2) + varb7*(MV^2)*(W3^2)                + 2*MV*covb1b4 + 2*W3*covb1b5 + 2*MV*W3*covb1b7 + 2*MV*W3*covb4b5                + 2*W3*(MV^2)*covb4b7 + 2*(W3^2)*MV*covb5b7) if _n<220;      gen t0=conb0/conse0;gen t1=conb1/conse1;gen t2=conb2/conse2;gen t3=conb3/conse3;gen consb0=conb0;gen consb1=conb1;gen consb2=conb2;gen consb3=conb3;replace consb0 = . if abs(t0)<1.96;replace consb1 = . if abs(t1)<1.96;replace consb2 = . if abs(t2)<1.96;replace consb3 = . if abs(t3)<1.96;generate str1 txt="*";

graph twoway   line conb0  MV,  clcolor(black) clpattern() clwidth(medthick)  /**/        ||  scatter consb0 MV, mlabel(txt) msymbol(i) mlabsize(vsmall) mlabgap(-1.0) mlabposition(11) /**/        ||     line conb1  MV,  clcolor(maroon) clpattern(dash) clwidth(medthick) /* */       ||  scatter consb1 MV,  mlabel(txt) msymbol(i) mlabsize(vsmall) mlabgap(-1.0) mlabposition(11)/*  */      ||     line conb2  MV,  clcolor(none)clpattern(dot) clwidth(medthick) /**/        ||  scatter consb2 MV,  mlabel() msymbol(i) mlabsize(vsmall) mlabgap(-1.0) mlabposition(11) /**/       ||     line conb3  MV,  clcolor(none) clpattern() clwidth() /**/        ||  scatter consb3 MV,  mlabel() msymbol(i) mlabsize(vsmall) mlabgap(-1.0) mlabposition(11)  /**/     graphregion(color(white))  /**/  ytitle(Marginal Effect of Change in Imports,size(3)) xtitle(Level of Import Openness (% GDP)) xlabel() yline(0, lcolor(black)) title("", size(3)) /**/  note(* = significance at 95%, size(2.5)) caption() /**/  title(Marginal effect of increasing imports on education spending (% Total Spending), size(2.75)) /*
*/  legend(off)

drop  MV conb0 conb1 conb2 conb3 conse0 conse1 conse2 conse3 t0 t1 t2 t3 consb0 consb1 consb2 consb3 txt



************************************************************
******************************TABLE 3 & FOOTNOTE 22: DVs MEASURED INSTEAD AS SHARE OF GDP******
************************************************************set more off
xi3:  xtpcse educgdp_change importld*importlag*dumlag educgdplag educgdpld lngdpcapld lngdpcaplag /*
*/ dependld dependlag dumld exportgdplag exportgdpld /*
*/ bn_cab_xoka_gd_zslag bn_cab_xoka_gd_zsld log_dt_dod_dect_cdlag log_dt_dod_dect_cdld year f1-f215 if oecd==0, paestimates store educ_gdp
estimates restore educ_gdp#delimit ;generate MV=((_n-1)/1);replace  MV=. if _n>220;scalar W0 =      0;scalar W1=     1;scalar W2=     0;scalar W3=       1;matrix b=e(b);matrix V=e(V);scalar b1=b[1,1];scalar b2=b[1,2];scalar b3=b[1,3];scalar b4=b[1,4];scalar b5=b[1,5];scalar b6=b[1,6];scalar b7=b[1,7];scalar varb1=V[1,1];scalar varb2=V[2,2];scalar varb3=V[3,3];scalar varb4=V[4,4];scalar varb5=V[5,5];scalar varb6=V[6,6];scalar varb7=V[7,7];scalar covb1b4=V[1,4];scalar covb1b5=V[1,5];scalar covb1b7=V[1,7];scalar covb4b5=V[4,5];scalar covb4b7=V[4,7];scalar covb5b7=V[5,7];scalar list b1 b2 b3 b4 b5 b6 b7 varb1 varb2 varb3 varb4 varb5 varb6 varb7             covb1b4 covb1b5 covb1b7 covb4b5 covb4b7 covb5b7;gen conb0=b1+b4*MV+b5*W0+b7*(MV*W0) if _n<220;gen conb1=b1+b4*MV+b5*W1+b7*(MV*W1) if _n<220;gen conb2=b1+b4*MV+b5*W2+b7*(MV*W2) if _n<220;gen conb3=b1+b4*MV+b5*W3+b7*(MV*W3) if _n<220;gen conse0=sqrt(varb1                + varb4*(MV^2) + varb5*(W0^2) + varb7*(MV^2)*(W0^2)                + 2*MV*covb1b4 + 2*W0*covb1b5 + 2*MV*W0*covb1b7 + 2*MV*W0*covb4b5                + 2*W0*(MV^2)*covb4b7 + 2*(W0^2)*MV*covb5b7) if _n<220;gen conse1=sqrt(varb1                + varb4*(MV^2) + varb5*(W1^2) + varb7*(MV^2)*(W1^2)                + 2*MV*covb1b4 + 2*W1*covb1b5 + 2*MV*W1*covb1b7 + 2*MV*W1*covb4b5                + 2*W1*(MV^2)*covb4b7 + 2*(W1^2)*MV*covb5b7) if _n<220;gen conse2=sqrt(varb1                + varb4*(MV^2) + varb5*(W2^2) + varb7*(MV^2)*(W2^2)                + 2*MV*covb1b4 + 2*W2*covb1b5 + 2*MV*W2*covb1b7 + 2*MV*W2*covb4b5                + 2*W2*(MV^2)*covb4b7 + 2*(W2^2)*MV*covb5b7) if _n<220;gen conse3=sqrt(varb1                + varb4*(MV^2) + varb5*(W3^2) + varb7*(MV^2)*(W3^2)                + 2*MV*covb1b4 + 2*W3*covb1b5 + 2*MV*W3*covb1b7 + 2*MV*W3*covb4b5                + 2*W3*(MV^2)*covb4b7 + 2*(W3^2)*MV*covb5b7) if _n<220;      gen t0=conb0/conse0;gen t1=conb1/conse1;gen t2=conb2/conse2;gen t3=conb3/conse3;gen consb0=conb0;gen consb1=conb1;gen consb2=conb2;gen consb3=conb3;replace consb0 = . if abs(t0)<1.96;replace consb1 = . if abs(t1)<1.96;replace consb2 = . if abs(t2)<1.96;replace consb3 = . if abs(t3)<1.96;generate str1 txt="*";

graph twoway   line conb0  MV,  clcolor(black) clpattern() clwidth(medthick)  /**/        ||  scatter consb0 MV, mlabel(txt) msymbol(i) mlabsize(vsmall) mlabgap(-1.0) mlabposition(11) /**/        ||     line conb1  MV,  clcolor(maroon) clpattern(dash) clwidth(medthick) /* */       ||  scatter consb1 MV,  mlabel(txt) msymbol(i) mlabsize(vsmall) mlabgap(-1.0) mlabposition(11)/*  */      ||     line conb2  MV,  clcolor(none)clpattern(dot) clwidth(medthick) /**/        ||  scatter consb2 MV,  mlabel() msymbol(i) mlabsize(vsmall) mlabgap(-1.0) mlabposition(11) /**/       ||     line conb3  MV,  clcolor(none) clpattern() clwidth() /**/        ||  scatter consb3 MV,  mlabel() msymbol(i) mlabsize(vsmall) mlabgap(-1.0) mlabposition(11)  /**/     graphregion(color(white))  /**/  ytitle(Marginal Effect of Change in Importss,size(3)) xtitle(Level of Imports (% GDP)) xlabel() yline(0, lcolor(black)) title("", size(3)) /**/  note(* = significance at 95%, size(2.5)) caption() /**/  title(Marginal effect of increasing imports on Education spending (% GDP), size(2.75)) /*
*/  legend(off)

drop  MV conb0 conb1 conb2 conb3 conse0 conse1 conse2 conse3 t0 t1 t2 t3 consb0 consb1 consb2 consb3 txt
xi3:  xtpcse welf_change importld*importlag*dumlag welflag welfld lngdpcapld lngdpcaplag /*
*/ dependld dependlag dumld exportgdplag exportgdpld /*
*/ bn_cab_xoka_gd_zslag bn_cab_xoka_gd_zsld log_dt_dod_dect_cdlag log_dt_dod_dect_cdld year f1-f215 if oecd==0, paestimates store welfare_gdpestimates restore welfare_gdp#delimit ;generate MV=((_n-1)/1);replace  MV=. if _n>220;scalar W0 =      0;scalar W1=     1;scalar W2=     0;scalar W3=       1;matrix b=e(b);matrix V=e(V);scalar b1=b[1,1];scalar b2=b[1,2];scalar b3=b[1,3];scalar b4=b[1,4];scalar b5=b[1,5];scalar b6=b[1,6];scalar b7=b[1,7];scalar varb1=V[1,1];scalar varb2=V[2,2];scalar varb3=V[3,3];scalar varb4=V[4,4];scalar varb5=V[5,5];scalar varb6=V[6,6];scalar varb7=V[7,7];scalar covb1b4=V[1,4];scalar covb1b5=V[1,5];scalar covb1b7=V[1,7];scalar covb4b5=V[4,5];scalar covb4b7=V[4,7];scalar covb5b7=V[5,7];scalar list b1 b2 b3 b4 b5 b6 b7 varb1 varb2 varb3 varb4 varb5 varb6 varb7             covb1b4 covb1b5 covb1b7 covb4b5 covb4b7 covb5b7;gen conb0=b1+b4*MV+b5*W0+b7*(MV*W0) if _n<220;gen conb1=b1+b4*MV+b5*W1+b7*(MV*W1) if _n<220;gen conb2=b1+b4*MV+b5*W2+b7*(MV*W2) if _n<220;gen conb3=b1+b4*MV+b5*W3+b7*(MV*W3) if _n<220;gen conse0=sqrt(varb1                + varb4*(MV^2) + varb5*(W0^2) + varb7*(MV^2)*(W0^2)                + 2*MV*covb1b4 + 2*W0*covb1b5 + 2*MV*W0*covb1b7 + 2*MV*W0*covb4b5                + 2*W0*(MV^2)*covb4b7 + 2*(W0^2)*MV*covb5b7) if _n<220;gen conse1=sqrt(varb1                + varb4*(MV^2) + varb5*(W1^2) + varb7*(MV^2)*(W1^2)                + 2*MV*covb1b4 + 2*W1*covb1b5 + 2*MV*W1*covb1b7 + 2*MV*W1*covb4b5                + 2*W1*(MV^2)*covb4b7 + 2*(W1^2)*MV*covb5b7) if _n<220;gen conse2=sqrt(varb1                + varb4*(MV^2) + varb5*(W2^2) + varb7*(MV^2)*(W2^2)                + 2*MV*covb1b4 + 2*W2*covb1b5 + 2*MV*W2*covb1b7 + 2*MV*W2*covb4b5                + 2*W2*(MV^2)*covb4b7 + 2*(W2^2)*MV*covb5b7) if _n<220;gen conse3=sqrt(varb1                + varb4*(MV^2) + varb5*(W3^2) + varb7*(MV^2)*(W3^2)                + 2*MV*covb1b4 + 2*W3*covb1b5 + 2*MV*W3*covb1b7 + 2*MV*W3*covb4b5                + 2*W3*(MV^2)*covb4b7 + 2*(W3^2)*MV*covb5b7) if _n<220;      gen t0=conb0/conse0;gen t1=conb1/conse1;gen t2=conb2/conse2;gen t3=conb3/conse3;gen consb0=conb0;gen consb1=conb1;gen consb2=conb2;gen consb3=conb3;replace consb0 = . if abs(t0)<1.96;replace consb1 = . if abs(t1)<1.96;replace consb2 = . if abs(t2)<1.96;replace consb3 = . if abs(t3)<1.96;generate str1 txt="*";

graph twoway   line conb0  MV,  clcolor(black) clpattern() clwidth(medthick)  /**/        ||  scatter consb0 MV, mlabel(txt) msymbol(i) mlabsize(vsmall) mlabgap(-1.0) mlabposition(11) /**/        ||     line conb1  MV,  clcolor(maroon) clpattern(dash) clwidth(medthick) /* */       ||  scatter consb1 MV,  mlabel(txt) msymbol(i) mlabsize(vsmall) mlabgap(-1.0) mlabposition(11)/*  */      ||     line conb2  MV,  clcolor(none)clpattern(dot) clwidth(medthick) /**/        ||  scatter consb2 MV,  mlabel() msymbol(i) mlabsize(vsmall) mlabgap(-1.0) mlabposition(11) /**/       ||     line conb3  MV,  clcolor(none) clpattern() clwidth() /**/        ||  scatter consb3 MV,  mlabel() msymbol(i) mlabsize(vsmall) mlabgap(-1.0) mlabposition(11)  /**/     graphregion(color(white))  /**/  ytitle(Marginal Effect of Change in Importss,size(3)) xtitle(Level of Imports (% GDP)) xlabel() yline(0, lcolor(black)) title("", size(3)) /**/  note(* = significance at 95%, size(2.5)) caption() /**/  title(Marginal effect of increasing imports on Welfare spending (% GDP), size(2.75)) /*
*/  legend(off)

drop  MV conb0 conb1 conb2 conb3 conse0 conse1 conse2 conse3 t0 t1 t2 t3 consb0 consb1 consb2 consb3 txt

estimates table educ_gdp welfare_gdp , /*
 */ b(%10.2f) se(%10.2f) p(%10.2f) stats(N ll aic bic) /*
 */ keep(importld importlag dumlag _IimXim _IimXdu _I1imXdu _IimXimXdu /*
 */ educgdplag educgdpld welflag welfld exportgdplag exportgdpld lngdpcapld /*
 */ lngdpcaplag dependld dependlag dumld bn_cab_xoka_gd_zslag bn_cab_xoka_gd_zsld  log_dt_dod_dect_cdlag log_dt_dod_dect_cdld year) label

************************************************************
******************************FOOTNOTE 24: TOTAL TRADE INSTEAD OF IMPORTS************************************************************xi3:  xtpcse educ_change tradeld*tradelag*dumlag educlag educld lngdpcapld lngdpcaplag dependld /*
*/ dependld dependlag dumld /*
*/ bn_cab_xoka_gd_zslag bn_cab_xoka_gd_zsld  log_dt_dod_dect_cdlag log_dt_dod_dect_cdld   year f1-f215 if oecd==0, pa
estimates store educ_trade_dum
estimates restore educ_trade_dum#delimit ;generate MV=((_n-1)/1);replace  MV=. if _n>220;scalar W0 =      0;scalar W1=     1;scalar W2=     0;scalar W3=       1;matrix b=e(b);matrix V=e(V);scalar b1=b[1,1];scalar b2=b[1,2];scalar b3=b[1,3];scalar b4=b[1,4];scalar b5=b[1,5];scalar b6=b[1,6];scalar b7=b[1,7];scalar varb1=V[1,1];scalar varb2=V[2,2];scalar varb3=V[3,3];scalar varb4=V[4,4];scalar varb5=V[5,5];scalar varb6=V[6,6];scalar varb7=V[7,7];scalar covb1b4=V[1,4];scalar covb1b5=V[1,5];scalar covb1b7=V[1,7];scalar covb4b5=V[4,5];scalar covb4b7=V[4,7];scalar covb5b7=V[5,7];scalar list b1 b2 b3 b4 b5 b6 b7 varb1 varb2 varb3 varb4 varb5 varb6 varb7             covb1b4 covb1b5 covb1b7 covb4b5 covb4b7 covb5b7;gen conb0=b1+b4*MV+b5*W0+b7*(MV*W0) if _n<220;gen conb1=b1+b4*MV+b5*W1+b7*(MV*W1) if _n<220;gen conb2=b1+b4*MV+b5*W2+b7*(MV*W2) if _n<220;gen conb3=b1+b4*MV+b5*W3+b7*(MV*W3) if _n<220;gen conse0=sqrt(varb1                + varb4*(MV^2) + varb5*(W0^2) + varb7*(MV^2)*(W0^2)                + 2*MV*covb1b4 + 2*W0*covb1b5 + 2*MV*W0*covb1b7 + 2*MV*W0*covb4b5                + 2*W0*(MV^2)*covb4b7 + 2*(W0^2)*MV*covb5b7) if _n<220;gen conse1=sqrt(varb1                + varb4*(MV^2) + varb5*(W1^2) + varb7*(MV^2)*(W1^2)                + 2*MV*covb1b4 + 2*W1*covb1b5 + 2*MV*W1*covb1b7 + 2*MV*W1*covb4b5                + 2*W1*(MV^2)*covb4b7 + 2*(W1^2)*MV*covb5b7) if _n<220;gen conse2=sqrt(varb1                + varb4*(MV^2) + varb5*(W2^2) + varb7*(MV^2)*(W2^2)                + 2*MV*covb1b4 + 2*W2*covb1b5 + 2*MV*W2*covb1b7 + 2*MV*W2*covb4b5                + 2*W2*(MV^2)*covb4b7 + 2*(W2^2)*MV*covb5b7) if _n<220;gen conse3=sqrt(varb1                + varb4*(MV^2) + varb5*(W3^2) + varb7*(MV^2)*(W3^2)                + 2*MV*covb1b4 + 2*W3*covb1b5 + 2*MV*W3*covb1b7 + 2*MV*W3*covb4b5                + 2*W3*(MV^2)*covb4b7 + 2*(W3^2)*MV*covb5b7) if _n<220;      gen t0=conb0/conse0;gen t1=conb1/conse1;gen t2=conb2/conse2;gen t3=conb3/conse3;gen consb0=conb0;gen consb1=conb1;gen consb2=conb2;gen consb3=conb3;replace consb0 = . if abs(t0)<1.96;replace consb1 = . if abs(t1)<1.96;replace consb2 = . if abs(t2)<1.96;replace consb3 = . if abs(t3)<1.96;generate str1 txt="*";

graph twoway   line conb0  MV,  clcolor(black) clpattern() clwidth(medthick)  /**/        ||  scatter consb0 MV, mlabel(txt) msymbol(i) mlabsize(vsmall) mlabgap(-1.0) mlabposition(11) /**/        ||     line conb1  MV,  clcolor(maroon) clpattern(dash) clwidth(medthick) /* */       ||  scatter consb1 MV,  mlabel(txt) msymbol(i) mlabsize(vsmall) mlabgap(-1.0) mlabposition(11)/*  */      ||     line conb2  MV,  clcolor(none)clpattern(dot) clwidth(medthick) /**/        ||  scatter consb2 MV,  mlabel() msymbol(i) mlabsize(vsmall) mlabgap(-1.0) mlabposition(11) /**/       ||     line conb3  MV,  clcolor(none) clpattern() clwidth() /**/        ||  scatter consb3 MV,  mlabel() msymbol(i) mlabsize(vsmall) mlabgap(-1.0) mlabposition(11)  /**/     graphregion(color(white))  /**/  ytitle(Marginal Effect of Change in Trade Openness,size(3)) xtitle(Level of Total Trade Openness (% GDP)) xlabel() yline(0, lcolor(black)) title("", size(3)) /**/  note(* = significance at 95%, size(2.5)) caption() /**/  title(Marginal effect of increasing imports on Education spending (% Total Spending), size(2.75)) /*
*/  legend(off)

drop  MV conb0 conb1 conb2 conb3 conse0 conse1 conse2 conse3 t0 t1 t2 t3 consb0 consb1 consb2 consb3 txt

xi3:  xtpcse welfg_change tradeld*tradelag*dumlag welfglag welfgld  lngdpcapld lngdpcaplag dependld /*
*/ dependld dependlag dumld /*
*/ bn_cab_xoka_gd_zslag bn_cab_xoka_gd_zsld  log_dt_dod_dect_cdlag log_dt_dod_dect_cdld   year f1-f215 if oecd==0, pa
estimates store welfg_trade_dum
estimates restore welfg_trade_dum#delimit ;generate MV=((_n-1)/1);replace  MV=. if _n>220;scalar W0 =      0;scalar W1=     1;scalar W2=     0;scalar W3=       1;matrix b=e(b);matrix V=e(V);scalar b1=b[1,1];scalar b2=b[1,2];scalar b3=b[1,3];scalar b4=b[1,4];scalar b5=b[1,5];scalar b6=b[1,6];scalar b7=b[1,7];scalar varb1=V[1,1];scalar varb2=V[2,2];scalar varb3=V[3,3];scalar varb4=V[4,4];scalar varb5=V[5,5];scalar varb6=V[6,6];scalar varb7=V[7,7];scalar covb1b4=V[1,4];scalar covb1b5=V[1,5];scalar covb1b7=V[1,7];scalar covb4b5=V[4,5];scalar covb4b7=V[4,7];scalar covb5b7=V[5,7];scalar list b1 b2 b3 b4 b5 b6 b7 varb1 varb2 varb3 varb4 varb5 varb6 varb7             covb1b4 covb1b5 covb1b7 covb4b5 covb4b7 covb5b7;gen conb0=b1+b4*MV+b5*W0+b7*(MV*W0) if _n<220;gen conb1=b1+b4*MV+b5*W1+b7*(MV*W1) if _n<220;gen conb2=b1+b4*MV+b5*W2+b7*(MV*W2) if _n<220;gen conb3=b1+b4*MV+b5*W3+b7*(MV*W3) if _n<220;gen conse0=sqrt(varb1                + varb4*(MV^2) + varb5*(W0^2) + varb7*(MV^2)*(W0^2)                + 2*MV*covb1b4 + 2*W0*covb1b5 + 2*MV*W0*covb1b7 + 2*MV*W0*covb4b5                + 2*W0*(MV^2)*covb4b7 + 2*(W0^2)*MV*covb5b7) if _n<220;gen conse1=sqrt(varb1                + varb4*(MV^2) + varb5*(W1^2) + varb7*(MV^2)*(W1^2)                + 2*MV*covb1b4 + 2*W1*covb1b5 + 2*MV*W1*covb1b7 + 2*MV*W1*covb4b5                + 2*W1*(MV^2)*covb4b7 + 2*(W1^2)*MV*covb5b7) if _n<220;gen conse2=sqrt(varb1                + varb4*(MV^2) + varb5*(W2^2) + varb7*(MV^2)*(W2^2)                + 2*MV*covb1b4 + 2*W2*covb1b5 + 2*MV*W2*covb1b7 + 2*MV*W2*covb4b5                + 2*W2*(MV^2)*covb4b7 + 2*(W2^2)*MV*covb5b7) if _n<220;gen conse3=sqrt(varb1                + varb4*(MV^2) + varb5*(W3^2) + varb7*(MV^2)*(W3^2)                + 2*MV*covb1b4 + 2*W3*covb1b5 + 2*MV*W3*covb1b7 + 2*MV*W3*covb4b5                + 2*W3*(MV^2)*covb4b7 + 2*(W3^2)*MV*covb5b7) if _n<220;      gen t0=conb0/conse0;gen t1=conb1/conse1;gen t2=conb2/conse2;gen t3=conb3/conse3;gen consb0=conb0;gen consb1=conb1;gen consb2=conb2;gen consb3=conb3;replace consb0 = . if abs(t0)<1.96;replace consb1 = . if abs(t1)<1.96;replace consb2 = . if abs(t2)<1.96;replace consb3 = . if abs(t3)<1.96;generate str1 txt="*";

graph twoway   line conb0  MV,  clcolor(black) clpattern() clwidth(medthick)  /**/        ||  scatter consb0 MV, mlabel(txt) msymbol(i) mlabsize(vsmall) mlabgap(-1.0) mlabposition(11) /**/        ||     line conb1  MV,  clcolor(maroon) clpattern(dash) clwidth(medthick) /* */       ||  scatter consb1 MV,  mlabel(txt) msymbol(i) mlabsize(vsmall) mlabgap(-1.0) mlabposition(11)/*  */      ||     line conb2  MV,  clcolor(none)clpattern(dot) clwidth(medthick) /**/        ||  scatter consb2 MV,  mlabel() msymbol(i) mlabsize(vsmall) mlabgap(-1.0) mlabposition(11) /**/       ||     line conb3  MV,  clcolor(none) clpattern() clwidth() /**/        ||  scatter consb3 MV,  mlabel() msymbol(i) mlabsize(vsmall) mlabgap(-1.0) mlabposition(11)  /**/     graphregion(color(white))  /**/  ytitle(Marginal Effect of Change in Trade Openness,size(3)) xtitle(Level of Total Trade Openness (% GDP)) xlabel() yline(0, lcolor(black)) title("", size(3)) /**/  note(* = significance at 95%, size(2.5)) caption() /**/  title(Marginal effect of increasing imports on Welfare spending (% Total Spending), size(2.75)) /*
*/  legend(off)

drop  MV conb0 conb1 conb2 conb3 conse0 conse1 conse2 conse3 t0 t1 t2 t3 consb0 consb1 consb2 consb3 txt
estimates table educ_trade_dum welfg_trade_dum , /*
 */ b(%10.2f) se(%10.2f) p(%10.2f) stats(N ll aic bic) /*
 */ keep(tradeld tradelag dumlag _ItrXtr _ItrXdu _I1trXdu _ItrXtrXdu /*
 */ educlag educld welfglag welfgld lngdpcapld /*
 */ lngdpcaplag dependld dependlag dumld bn_cab_xoka_gd_zslag bn_cab_xoka_gd_zsld  log_dt_dod_dect_cdlag log_dt_dod_dect_cdld year) label

************************************************************
******************************FOOTNOTE 25: SPLIT SAMPLE INSTEAD OF TRIPLE INTERACTIONS******
************************************************************
reg educ_change importld importlag importldXimportlag educlag educld lngdpcapld lngdpcaplag /*
*/ dependld dependlag exportgdplag exportgdpld /*
*/ bn_cab_xoka_gd_zslag bn_cab_xoka_gd_zsld log_dt_dod_dect_cdlag log_dt_dod_dect_cdld year f1-f215 /*
*/ if oecd==0&dumlag==0, cluster(ctrycode)estimates store educ_nondems
estimates restore educ_nondems
#delimit ;generate MV=((_n-1)/1);replace  MV=. if _n>220;matrix b=e(b); matrix V=e(V);scalar b1=b[1,1]; scalar b2=b[1,2];scalar b3=b[1,3];scalar varb1=V[1,1]; scalar varb2=V[2,2]; scalar varb3=V[3,3];scalar covb1b3=V[1,3]; scalar covb2b3=V[2,3];scalar list b1 b2 b3 varb1 varb2 varb3 covb1b3 covb2b3;gen conb=b1+b3*MV if _n<220;gen conse=sqrt(varb1+varb3*(MV^2)+2*covb1b3*MV) if _n<220; gen a=1.65*conse;gen upper=conb+a;gen lower=conb-a;graph twoway line conb   MV, clwidth(medium) clcolor(black)      || line upper  MV, clpattern(dash) clwidth(medium) clcolor(black)      || line lower  MV, clpattern(dash) clwidth(medium) clcolor(black)     || hist importlag if e(sample), yaxis(2) bfcolor(none) blcolor(gray) blwidth(thin)     blpattern() bin(12) percent ytitle(Distribution of Level of Imports (Percent), axis(2)) ,   xlabel() title(Education: Non-Democracies, size(2.75))  ytitle(Marginal Effect of Change in Imports)       legend(col(1) order(1 2) label(1 "")     label(2 "95% Confidence Interval")  label(3 " ")) legend(off) yline(0, lcolor(black))       caption(, size(2.5)) xtitle(Level of Import Openness) note("", size(2)) graphregion(color(white));
drop MV conb conse a upper lower;

reg educ_change importld importlag importldXimportlag educlag educld lngdpcapld lngdpcaplag /*
*/ dependld dependlag exportgdplag exportgdpld /*
*/ bn_cab_xoka_gd_zslag bn_cab_xoka_gd_zsld log_dt_dod_dect_cdlag log_dt_dod_dect_cdld year f1-f215 /*
*/ if oecd==0&dumlag==1, cluster(ctrycode)estimates store educ_dems
estimates restore educ_dems
#delimit ;generate MV=((_n-1)/1);replace  MV=. if _n>220;matrix b=e(b); matrix V=e(V);scalar b1=b[1,1]; scalar b2=b[1,2];scalar b3=b[1,3];scalar varb1=V[1,1]; scalar varb2=V[2,2]; scalar varb3=V[3,3];scalar covb1b3=V[1,3]; scalar covb2b3=V[2,3];scalar list b1 b2 b3 varb1 varb2 varb3 covb1b3 covb2b3;gen conb=b1+b3*MV if _n<220;gen conse=sqrt(varb1+varb3*(MV^2)+2*covb1b3*MV) if _n<220; gen a=1.65*conse;gen upper=conb+a;gen lower=conb-a;graph twoway line conb   MV, clwidth(medium) clcolor(black)      || line upper  MV, clpattern(dash) clwidth(medium) clcolor(black)      || line lower  MV, clpattern(dash) clwidth(medium) clcolor(black)     || hist importlag if e(sample), yaxis(2) bfcolor(none) blcolor(gray) blwidth(thin)     blpattern() bin(12) percent ytitle(Distribution of Level of Imports (Percent), axis(2)) ,   xlabel() title(Education: Democracies, size(2.75))  ytitle(Marginal Effect of Change in Imports)       legend(col(1) order(1 2) label(1 "")     label(2 "95% Confidence Interval")  label(3 " ")) legend(off) yline(0, lcolor(black))       caption(, size(2.5)) xtitle(Level of Import Openness) note("", size(2)) graphregion(color(white));
drop MV conb conse a upper lower;

reg welfg_change importld importlag importldXimportlag welfglag welfgld lngdpcapld lngdpcaplag /*
*/ dependld dependlag exportgdplag exportgdpld /*
*/ bn_cab_xoka_gd_zslag bn_cab_xoka_gd_zsld log_dt_dod_dect_cdlag log_dt_dod_dect_cdld year f1-f215 /*
*/ if oecd==0&dumlag==0, cluster(ctrycode)estimates store welfg_nondems
estimates restore welfg_nondems
#delimit ;generate MV=((_n-1)/1);replace  MV=. if _n>220;matrix b=e(b); matrix V=e(V);scalar b1=b[1,1]; scalar b2=b[1,2];scalar b3=b[1,3];scalar varb1=V[1,1]; scalar varb2=V[2,2]; scalar varb3=V[3,3];scalar covb1b3=V[1,3]; scalar covb2b3=V[2,3];scalar list b1 b2 b3 varb1 varb2 varb3 covb1b3 covb2b3;gen conb=b1+b3*MV if _n<220;gen conse=sqrt(varb1+varb3*(MV^2)+2*covb1b3*MV) if _n<220; gen a=1.65*conse;gen upper=conb+a;gen lower=conb-a;graph twoway line conb   MV, clwidth(medium) clcolor(black)      || line upper  MV, clpattern(dash) clwidth(medium) clcolor(black)      || line lower  MV, clpattern(dash) clwidth(medium) clcolor(black)     || hist importlag if e(sample), yaxis(2) bfcolor(none) blcolor(gray) blwidth(thin)     blpattern() bin(12) percent ytitle(Distribution of Level of Imports (Percent), axis(2)) ,   xlabel() title(Welfare: Non-democracies, size(2.75))  ytitle(Marginal Effect of Change in Imports)       legend(col(1) order(1 2) label(1 "")     label(2 "95% Confidence Interval")  label(3 " ")) legend(off) yline(0, lcolor(black))       caption(, size(2.5)) xtitle(Level of Import Openness) note("", size(2)) graphregion(color(white));
drop MV conb conse a upper lower;

reg welfg_change importld importlag importldXimportlag welfglag welfgld lngdpcapld lngdpcaplag /*
*/ dependld dependlag exportgdplag exportgdpld /*
*/ bn_cab_xoka_gd_zslag bn_cab_xoka_gd_zsld log_dt_dod_dect_cdlag log_dt_dod_dect_cdld year f1-f215 /*
*/ if oecd==0&dumlag==1, cluster(ctrycode)estimates store welfg_dems
estimates restore welfg_dems
#delimit ;generate MV=((_n-1)/1);replace  MV=. if _n>220;matrix b=e(b); matrix V=e(V);scalar b1=b[1,1]; scalar b2=b[1,2];scalar b3=b[1,3];scalar varb1=V[1,1]; scalar varb2=V[2,2]; scalar varb3=V[3,3];scalar covb1b3=V[1,3]; scalar covb2b3=V[2,3];scalar list b1 b2 b3 varb1 varb2 varb3 covb1b3 covb2b3;gen conb=b1+b3*MV if _n<220;gen conse=sqrt(varb1+varb3*(MV^2)+2*covb1b3*MV) if _n<220; gen a=1.65*conse;gen upper=conb+a;gen lower=conb-a;graph twoway line conb   MV, clwidth(medium) clcolor(black)      || line upper  MV, clpattern(dash) clwidth(medium) clcolor(black)      || line lower  MV, clpattern(dash) clwidth(medium) clcolor(black)     || hist importlag if e(sample), yaxis(2) bfcolor(none) blcolor(gray) blwidth(thin)     blpattern() bin(12) percent ytitle(Distribution of Level of Imports (Percent), axis(2)) ,   xlabel() title(Welfare: Democracies, size(2.75))  ytitle(Marginal Effect of Change in Imports)       legend(col(1) order(1 2) label(1 "")     label(2 "95% Confidence Interval")  label(3 " ")) legend(off) yline(0, lcolor(black))       caption(, size(2.5)) xtitle(Level of Import Openness) note("", size(2)) graphregion(color(white));
drop MV conb conse a upper lower;

estimates table educ_nondems educ_dems welfg_nondems welfg_dems , /*
 */ b(%10.2f) se(%10.2f) p(%10.2f) stats(N) /*
 */ keep(importld importlag importldXimportlag /*
 */ educlag educld welfglag welfgld exportgdplag exportgdpld lngdpcapld /*
 */ lngdpcaplag dependld dependlag bn_cab_xoka_gd_zslag bn_cab_xoka_gd_zsld /*
 */ log_dt_dod_dect_cdlag log_dt_dod_dect_cdld year) label

************************************************************
******************************TABLE 3: SENSITIVITY ANALYSIS
************************************************************
set more offxi3:  xtpcse educ_change importld*importlag*pollag educlag educld lngdpcapld lngdpcaplag /*
*/ dependld dependlag polld exportgdplag exportgdpld /*
*/ bn_cab_xoka_gd_zslag bn_cab_xoka_gd_zsld  log_dt_dod_dect_cdlag log_dt_dod_dect_cdld   year f1-f215 if oecd==0, paestimates store educ_polity2
estimates restore educ_polity2#delimit ;generate MV=((_n-1)/1);replace  MV=. if _n>220;scalar W0 =      -10;scalar W1=     -5;scalar W2=     5;scalar W3=       10;matrix b=e(b);matrix V=e(V);scalar b1=b[1,1];scalar b2=b[1,2];scalar b3=b[1,3];scalar b4=b[1,4];scalar b5=b[1,5];scalar b6=b[1,6];scalar b7=b[1,7];scalar varb1=V[1,1];scalar varb2=V[2,2];scalar varb3=V[3,3];scalar varb4=V[4,4];scalar varb5=V[5,5];scalar varb6=V[6,6];scalar varb7=V[7,7];scalar covb1b4=V[1,4];scalar covb1b5=V[1,5];scalar covb1b7=V[1,7];scalar covb4b5=V[4,5];scalar covb4b7=V[4,7];scalar covb5b7=V[5,7];scalar list b1 b2 b3 b4 b5 b6 b7 varb1 varb2 varb3 varb4 varb5 varb6 varb7             covb1b4 covb1b5 covb1b7 covb4b5 covb4b7 covb5b7;gen conb0=b1+b4*MV+b5*W0+b7*(MV*W0) if _n<220;gen conb1=b1+b4*MV+b5*W1+b7*(MV*W1) if _n<220;gen conb2=b1+b4*MV+b5*W2+b7*(MV*W2) if _n<220;gen conb3=b1+b4*MV+b5*W3+b7*(MV*W3) if _n<220;gen conse0=sqrt(varb1                + varb4*(MV^2) + varb5*(W0^2) + varb7*(MV^2)*(W0^2)                + 2*MV*covb1b4 + 2*W0*covb1b5 + 2*MV*W0*covb1b7 + 2*MV*W0*covb4b5                + 2*W0*(MV^2)*covb4b7 + 2*(W0^2)*MV*covb5b7) if _n<220;gen conse1=sqrt(varb1                + varb4*(MV^2) + varb5*(W1^2) + varb7*(MV^2)*(W1^2)                + 2*MV*covb1b4 + 2*W1*covb1b5 + 2*MV*W1*covb1b7 + 2*MV*W1*covb4b5                + 2*W1*(MV^2)*covb4b7 + 2*(W1^2)*MV*covb5b7) if _n<220;gen conse2=sqrt(varb1                + varb4*(MV^2) + varb5*(W2^2) + varb7*(MV^2)*(W2^2)                + 2*MV*covb1b4 + 2*W2*covb1b5 + 2*MV*W2*covb1b7 + 2*MV*W2*covb4b5                + 2*W2*(MV^2)*covb4b7 + 2*(W2^2)*MV*covb5b7) if _n<220;gen conse3=sqrt(varb1                + varb4*(MV^2) + varb5*(W3^2) + varb7*(MV^2)*(W3^2)                + 2*MV*covb1b4 + 2*W3*covb1b5 + 2*MV*W3*covb1b7 + 2*MV*W3*covb4b5                + 2*W3*(MV^2)*covb4b7 + 2*(W3^2)*MV*covb5b7) if _n<220;      gen t0=conb0/conse0;gen t1=conb1/conse1;gen t2=conb2/conse2;gen t3=conb3/conse3;gen consb0=conb0;gen consb1=conb1;gen consb2=conb2;gen consb3=conb3;replace consb0 = . if abs(t0)<1.96;replace consb1 = . if abs(t1)<1.96;replace consb2 = . if abs(t2)<1.96;replace consb3 = . if abs(t3)<1.96;generate str1 txt="*";

graph twoway   line conb0  MV,  clcolor(black) clpattern() clwidth(thick)  /**/        ||  scatter consb0 MV, mlabel(txt) msymbol(i) mlabsize(vsmall) mlabgap(-1.0) mlabposition(11) /**/        ||     line conb1  MV,  clcolor(black) clpattern(dash) clwidth(medthick) /* */       ||  scatter consb1 MV,  mlabel(txt) msymbol(i) mlabsize(vsmall) mlabgap(-1.0) mlabposition(11)/*  */      ||     line conb2  MV,  clcolor(maroon)clpattern(dot) clwidth(medthick) /**/        ||  scatter consb2 MV,  mlabel(txt) msymbol(i) mlabsize(vsmall) mlabgap(-1.0) mlabposition(11) /**/       ||     line conb3  MV,  clcolor(maroon) clpattern() clwidth(thick) /**/        ||  scatter consb3 MV,  mlabel(txt) msymbol(i) mlabsize(vsmall) mlabgap(-1.0) mlabposition(11)  /**/     graphregion(color(white))  /**/  ytitle(Marginal Effect of Change in Importss,size(3)) xtitle(Level of Imports (% GDP)) xlabel() yline(0, lcolor(black)) title("", size(3)) /**/  note(* = significance at 95%, size(2.5)) caption() /**/  title(Marginal effect of increasing imports on Education spending (% Total Spending), size(2.75)) /*
*/  legend(off)

drop  MV conb0 conb1 conb2 conb3 conse0 conse1 conse2 conse3 t0 t1 t2 t3 consb0 consb1 consb2 consb3 txt

xi3:  xtpcse welfg_change importld*importlag*pollag welfglag welfgld lngdpcapld lngdpcaplag /*
*/ dependld dependlag polld exportgdplag exportgdpld /*
*/ bn_cab_xoka_gd_zslag bn_cab_xoka_gd_zsld  log_dt_dod_dect_cdlag log_dt_dod_dect_cdld   year f1-f215 if oecd==0, paestimates store welfg_polity2
estimates restore welfg_polity2#delimit ;generate MV=((_n-1)/1);replace  MV=. if _n>220;scalar W0 =      -10;scalar W1=     -5;scalar W2=     5;scalar W3=       10;matrix b=e(b);matrix V=e(V);scalar b1=b[1,1];scalar b2=b[1,2];scalar b3=b[1,3];scalar b4=b[1,4];scalar b5=b[1,5];scalar b6=b[1,6];scalar b7=b[1,7];scalar varb1=V[1,1];scalar varb2=V[2,2];scalar varb3=V[3,3];scalar varb4=V[4,4];scalar varb5=V[5,5];scalar varb6=V[6,6];scalar varb7=V[7,7];scalar covb1b4=V[1,4];scalar covb1b5=V[1,5];scalar covb1b7=V[1,7];scalar covb4b5=V[4,5];scalar covb4b7=V[4,7];scalar covb5b7=V[5,7];scalar list b1 b2 b3 b4 b5 b6 b7 varb1 varb2 varb3 varb4 varb5 varb6 varb7             covb1b4 covb1b5 covb1b7 covb4b5 covb4b7 covb5b7;gen conb0=b1+b4*MV+b5*W0+b7*(MV*W0) if _n<220;gen conb1=b1+b4*MV+b5*W1+b7*(MV*W1) if _n<220;gen conb2=b1+b4*MV+b5*W2+b7*(MV*W2) if _n<220;gen conb3=b1+b4*MV+b5*W3+b7*(MV*W3) if _n<220;gen conse0=sqrt(varb1                + varb4*(MV^2) + varb5*(W0^2) + varb7*(MV^2)*(W0^2)                + 2*MV*covb1b4 + 2*W0*covb1b5 + 2*MV*W0*covb1b7 + 2*MV*W0*covb4b5                + 2*W0*(MV^2)*covb4b7 + 2*(W0^2)*MV*covb5b7) if _n<220;gen conse1=sqrt(varb1                + varb4*(MV^2) + varb5*(W1^2) + varb7*(MV^2)*(W1^2)                + 2*MV*covb1b4 + 2*W1*covb1b5 + 2*MV*W1*covb1b7 + 2*MV*W1*covb4b5                + 2*W1*(MV^2)*covb4b7 + 2*(W1^2)*MV*covb5b7) if _n<220;gen conse2=sqrt(varb1                + varb4*(MV^2) + varb5*(W2^2) + varb7*(MV^2)*(W2^2)                + 2*MV*covb1b4 + 2*W2*covb1b5 + 2*MV*W2*covb1b7 + 2*MV*W2*covb4b5                + 2*W2*(MV^2)*covb4b7 + 2*(W2^2)*MV*covb5b7) if _n<220;gen conse3=sqrt(varb1                + varb4*(MV^2) + varb5*(W3^2) + varb7*(MV^2)*(W3^2)                + 2*MV*covb1b4 + 2*W3*covb1b5 + 2*MV*W3*covb1b7 + 2*MV*W3*covb4b5                + 2*W3*(MV^2)*covb4b7 + 2*(W3^2)*MV*covb5b7) if _n<220;      gen t0=conb0/conse0;gen t1=conb1/conse1;gen t2=conb2/conse2;gen t3=conb3/conse3;gen consb0=conb0;gen consb1=conb1;gen consb2=conb2;gen consb3=conb3;replace consb0 = . if abs(t0)<1.96;replace consb1 = . if abs(t1)<1.96;replace consb2 = . if abs(t2)<1.96;replace consb3 = . if abs(t3)<1.96;generate str1 txt="*";

graph twoway   line conb0  MV,  clcolor(black) clpattern() clwidth(thick)  /**/        ||  scatter consb0 MV, mlabel(txt) msymbol(i) mlabsize(vsmall) mlabgap(-1.0) mlabposition(11) /**/        ||     line conb1  MV,  clcolor(black) clpattern(dash) clwidth(medthick) /* */       ||  scatter consb1 MV,  mlabel(txt) msymbol(i) mlabsize(vsmall) mlabgap(-1.0) mlabposition(11)/*  */      ||     line conb2  MV,  clcolor(maroon)clpattern(dot) clwidth(medthick) /**/        ||  scatter consb2 MV,  mlabel(txt) msymbol(i) mlabsize(vsmall) mlabgap(-1.0) mlabposition(11) /**/       ||     line conb3  MV,  clcolor(maroon) clpattern() clwidth(thick) /**/        ||  scatter consb3 MV,  mlabel(txt) msymbol(i) mlabsize(vsmall) mlabgap(-1.0) mlabposition(11)  /**/     graphregion(color(white))  /**/  ytitle(Marginal Effect of Change in Importss,size(3)) xtitle(Level of Imports (% GDP)) xlabel() yline(0, lcolor(black)) title("", size(3)) /**/  note(* = significance at 95%, size(2.5)) caption() /**/  title(Marginal effect of increasing imports on Welfare spending (% Total Spending), size(2.75)) /*
*/  legend(off)

drop  MV conb0 conb1 conb2 conb3 conse0 conse1 conse2 conse3 t0 t1 t2 t3 consb0 consb1 consb2 consb3 txt

estimates table educ_polity2 welfg_polity2 , /*
 */ b(%10.2f) se(%10.2f) p(%10.2f) stats(N ll aic bic) /*
 */ keep(importld importlag pollag _IimXim _IimXpo _I1imXpo _IimXimXpo /*
 */ educlag educld welfglag welfgld exportgdplag exportgdpld lngdpcapld /*
 */ lngdpcaplag dependld dependlag polld bn_cab_xoka_gd_zslag bn_cab_xoka_gd_zsld /*
 */ log_dt_dod_dect_cdlag log_dt_dod_dect_cdld year) label

************************************************************
*****************************FOOTNOTE 31: USING TRICHOTOMOUS CODING OF POLITY******
************************************************************
set more offxi3:  xtpcse educ_change importld*importlag*pol3lag educlag educld lngdpcapld lngdpcaplag /*
*/ dependld dependlag pol3ld exportgdplag exportgdpld /*
*/ bn_cab_xoka_gd_zslag bn_cab_xoka_gd_zsld  log_dt_dod_dect_cdlag log_dt_dod_dect_cdld   year f1-f215 if oecd==0, paestimates store educ_pol3
estimates restore educ_pol3#delimit ;generate MV=((_n-1)/1);replace  MV=. if _n>220;scalar W0 =      0;scalar W1=     1;scalar W2=     2;scalar W3=      0;matrix b=e(b);matrix V=e(V);scalar b1=b[1,1];scalar b2=b[1,2];scalar b3=b[1,3];scalar b4=b[1,4];scalar b5=b[1,5];scalar b6=b[1,6];scalar b7=b[1,7];scalar varb1=V[1,1];scalar varb2=V[2,2];scalar varb3=V[3,3];scalar varb4=V[4,4];scalar varb5=V[5,5];scalar varb6=V[6,6];scalar varb7=V[7,7];scalar covb1b4=V[1,4];scalar covb1b5=V[1,5];scalar covb1b7=V[1,7];scalar covb4b5=V[4,5];scalar covb4b7=V[4,7];scalar covb5b7=V[5,7];scalar list b1 b2 b3 b4 b5 b6 b7 varb1 varb2 varb3 varb4 varb5 varb6 varb7             covb1b4 covb1b5 covb1b7 covb4b5 covb4b7 covb5b7;gen conb0=b1+b4*MV+b5*W0+b7*(MV*W0) if _n<220;gen conb1=b1+b4*MV+b5*W1+b7*(MV*W1) if _n<220;gen conb2=b1+b4*MV+b5*W2+b7*(MV*W2) if _n<220;gen conb3=b1+b4*MV+b5*W3+b7*(MV*W3) if _n<220;gen conse0=sqrt(varb1                + varb4*(MV^2) + varb5*(W0^2) + varb7*(MV^2)*(W0^2)                + 2*MV*covb1b4 + 2*W0*covb1b5 + 2*MV*W0*covb1b7 + 2*MV*W0*covb4b5                + 2*W0*(MV^2)*covb4b7 + 2*(W0^2)*MV*covb5b7) if _n<220;gen conse1=sqrt(varb1                + varb4*(MV^2) + varb5*(W1^2) + varb7*(MV^2)*(W1^2)                + 2*MV*covb1b4 + 2*W1*covb1b5 + 2*MV*W1*covb1b7 + 2*MV*W1*covb4b5                + 2*W1*(MV^2)*covb4b7 + 2*(W1^2)*MV*covb5b7) if _n<220;gen conse2=sqrt(varb1                + varb4*(MV^2) + varb5*(W2^2) + varb7*(MV^2)*(W2^2)                + 2*MV*covb1b4 + 2*W2*covb1b5 + 2*MV*W2*covb1b7 + 2*MV*W2*covb4b5                + 2*W2*(MV^2)*covb4b7 + 2*(W2^2)*MV*covb5b7) if _n<220;gen conse3=sqrt(varb1                + varb4*(MV^2) + varb5*(W3^2) + varb7*(MV^2)*(W3^2)                + 2*MV*covb1b4 + 2*W3*covb1b5 + 2*MV*W3*covb1b7 + 2*MV*W3*covb4b5                + 2*W3*(MV^2)*covb4b7 + 2*(W3^2)*MV*covb5b7) if _n<220;      gen t0=conb0/conse0;gen t1=conb1/conse1;gen t2=conb2/conse2;gen t3=conb3/conse3;gen consb0=conb0;gen consb1=conb1;gen consb2=conb2;gen consb3=conb3;replace consb0 = . if abs(t0)<1.96;replace consb1 = . if abs(t1)<1.96;replace consb2 = . if abs(t2)<1.96;replace consb3 = . if abs(t3)<1.96;generate str1 txt="*";

graph twoway   line conb0  MV,  clcolor(black) clpattern() clwidth(thick)  /**/        ||  scatter consb0 MV, mlabel(txt) msymbol(i) mlabsize(vsmall) mlabgap(-1.0) mlabposition(11) /**/        ||     line conb1  MV,  clcolor(blue) clpattern(dash) clwidth(medthick) /* */       ||  scatter consb1 MV,  mlabel(txt) msymbol(i) mlabsize(vsmall) mlabgap(-1.0) mlabposition(11)/*  */      ||     line conb2  MV,  clcolor(maroon) clpattern(dot) clwidth(thick) /**/        ||  scatter consb2 MV,  mlabel(txt) msymbol(i) mlabsize(vsmall) mlabgap(-1.0) mlabposition(11) /**/       ||     line conb3  MV,  clcolor(none) clpattern() clwidth() /**/        ||  scatter consb3 MV,  mlabel(txt) msymbol(i) mlabsize(vsmall) mlabgap(-1.0) mlabposition(11)  /**/     graphregion(color(white))  /**/  ytitle(Marginal Effect of Change in Importss,size(3)) xtitle(Level of Imports (% GDP)) xlabel() yline(0, lcolor(black)) title("", size(3)) /**/  note(* = significance at 95%, size(2.5)) caption() /**/  title(Marginal effect of increasing imports on Education spending (% Total Spending), size(2.75)) /*
*/  legend(off)

drop  MV conb0 conb1 conb2 conb3 conse0 conse1 conse2 conse3 t0 t1 t2 t3 consb0 consb1 consb2 consb3 txt

xi3:  xtpcse welfg_change importld*importlag*pol3lag welfglag welfgld lngdpcapld lngdpcaplag /*
*/ dependld dependlag pol3ld exportgdplag exportgdpld /*
*/ bn_cab_xoka_gd_zslag bn_cab_xoka_gd_zsld  log_dt_dod_dect_cdlag log_dt_dod_dect_cdld   year f1-f215 if oecd==0, paestimates store welfg_pol3
estimates restore welfg_pol3#delimit ;generate MV=((_n-1)/1);replace  MV=. if _n>220;scalar W0 =      0;scalar W1=     1;scalar W2=     2;scalar W3=      0;matrix b=e(b);matrix V=e(V);scalar b1=b[1,1];scalar b2=b[1,2];scalar b3=b[1,3];scalar b4=b[1,4];scalar b5=b[1,5];scalar b6=b[1,6];scalar b7=b[1,7];scalar varb1=V[1,1];scalar varb2=V[2,2];scalar varb3=V[3,3];scalar varb4=V[4,4];scalar varb5=V[5,5];scalar varb6=V[6,6];scalar varb7=V[7,7];scalar covb1b4=V[1,4];scalar covb1b5=V[1,5];scalar covb1b7=V[1,7];scalar covb4b5=V[4,5];scalar covb4b7=V[4,7];scalar covb5b7=V[5,7];scalar list b1 b2 b3 b4 b5 b6 b7 varb1 varb2 varb3 varb4 varb5 varb6 varb7             covb1b4 covb1b5 covb1b7 covb4b5 covb4b7 covb5b7;gen conb0=b1+b4*MV+b5*W0+b7*(MV*W0) if _n<220;gen conb1=b1+b4*MV+b5*W1+b7*(MV*W1) if _n<220;gen conb2=b1+b4*MV+b5*W2+b7*(MV*W2) if _n<220;gen conb3=b1+b4*MV+b5*W3+b7*(MV*W3) if _n<220;gen conse0=sqrt(varb1                + varb4*(MV^2) + varb5*(W0^2) + varb7*(MV^2)*(W0^2)                + 2*MV*covb1b4 + 2*W0*covb1b5 + 2*MV*W0*covb1b7 + 2*MV*W0*covb4b5                + 2*W0*(MV^2)*covb4b7 + 2*(W0^2)*MV*covb5b7) if _n<220;gen conse1=sqrt(varb1                + varb4*(MV^2) + varb5*(W1^2) + varb7*(MV^2)*(W1^2)                + 2*MV*covb1b4 + 2*W1*covb1b5 + 2*MV*W1*covb1b7 + 2*MV*W1*covb4b5                + 2*W1*(MV^2)*covb4b7 + 2*(W1^2)*MV*covb5b7) if _n<220;gen conse2=sqrt(varb1                + varb4*(MV^2) + varb5*(W2^2) + varb7*(MV^2)*(W2^2)                + 2*MV*covb1b4 + 2*W2*covb1b5 + 2*MV*W2*covb1b7 + 2*MV*W2*covb4b5                + 2*W2*(MV^2)*covb4b7 + 2*(W2^2)*MV*covb5b7) if _n<220;gen conse3=sqrt(varb1                + varb4*(MV^2) + varb5*(W3^2) + varb7*(MV^2)*(W3^2)                + 2*MV*covb1b4 + 2*W3*covb1b5 + 2*MV*W3*covb1b7 + 2*MV*W3*covb4b5                + 2*W3*(MV^2)*covb4b7 + 2*(W3^2)*MV*covb5b7) if _n<220;      gen t0=conb0/conse0;gen t1=conb1/conse1;gen t2=conb2/conse2;gen t3=conb3/conse3;gen consb0=conb0;gen consb1=conb1;gen consb2=conb2;gen consb3=conb3;replace consb0 = . if abs(t0)<1.96;replace consb1 = . if abs(t1)<1.96;replace consb2 = . if abs(t2)<1.96;replace consb3 = . if abs(t3)<1.96;generate str1 txt="*";

graph twoway   line conb0  MV,  clcolor(black) clpattern() clwidth(thick)  /**/        ||  scatter consb0 MV, mlabel(txt) msymbol(i) mlabsize(vsmall) mlabgap(-1.0) mlabposition(11) /**/        ||     line conb1  MV,  clcolor(blue) clpattern(dash) clwidth(medthick) /* */       ||  scatter consb1 MV,  mlabel(txt) msymbol(i) mlabsize(vsmall) mlabgap(-1.0) mlabposition(11)/*  */      ||     line conb2  MV,  clcolor(maroon) clpattern(dot) clwidth(thick) /**/        ||  scatter consb2 MV,  mlabel(txt) msymbol(i) mlabsize(vsmall) mlabgap(-1.0) mlabposition(11) /**/       ||     line conb3  MV,  clcolor(none) clpattern() clwidth() /**/        ||  scatter consb3 MV,  mlabel(txt) msymbol(i) mlabsize(vsmall) mlabgap(-1.0) mlabposition(11)  /**/     graphregion(color(white))  /**/  ytitle(Marginal Effect of Change in Importss,size(3)) xtitle(Level of Imports (% GDP)) xlabel() yline(0, lcolor(black)) title("", size(3)) /**/  note(* = significance at 95%, size(2.5)) caption() /**/  title(Marginal effect of increasing imports on Welfare spending (% Total Spending), size(2.75)) /*
*/  legend(off)

drop  MV conb0 conb1 conb2 conb3 conse0 conse1 conse2 conse3 t0 t1 t2 t3 consb0 consb1 consb2 consb3 txt

estimates table educ_pol3 welfg_pol3 , /*
 */ b(%10.2f) se(%10.2f) p(%10.2f) stats(N ll aic bic) /*
 */ keep(importld importlag pol3lag _IimXim _IimXpo _I1imXpo _IimXimXpo /*
 */ educlag educld welfglag welfgld exportgdplag exportgdpld lngdpcapld /*
 */ lngdpcaplag dependld dependlag pol3ld bn_cab_xoka_gd_zslag bn_cab_xoka_gd_zsld /*
 */ log_dt_dod_dect_cdlag log_dt_dod_dect_cdld year) label

************************************************************
******************************ROBUSTNESS: FLIPPING THE DICHOTMOUS POLITY SCALE SO THAT DICTATORSHIPS == 1******
************************************************************
set more offxi3:  xtpcse educ_change importld*importlag*pdirvlag educlag educld lngdpcapld lngdpcaplag /*
*/ dependld dependlag polity_di_revld exportgdplag exportgdpld /*
*/ bn_cab_xoka_gd_zslag bn_cab_xoka_gd_zsld  log_dt_dod_dect_cdlag log_dt_dod_dect_cdld   year f1-f215 if oecd==0, paestimates store educ_poldirev
estimates restore educ_poldirev#delimit ;generate MV=((_n-1)/1);replace  MV=. if _n>220;scalar W0 =      0;scalar W1=     1;scalar W2=     0;scalar W3=       1;matrix b=e(b);matrix V=e(V);scalar b1=b[1,1];scalar b2=b[1,2];scalar b3=b[1,3];scalar b4=b[1,4];scalar b5=b[1,5];scalar b6=b[1,6];scalar b7=b[1,7];scalar varb1=V[1,1];scalar varb2=V[2,2];scalar varb3=V[3,3];scalar varb4=V[4,4];scalar varb5=V[5,5];scalar varb6=V[6,6];scalar varb7=V[7,7];scalar covb1b4=V[1,4];scalar covb1b5=V[1,5];scalar covb1b7=V[1,7];scalar covb4b5=V[4,5];scalar covb4b7=V[4,7];scalar covb5b7=V[5,7];scalar list b1 b2 b3 b4 b5 b6 b7 varb1 varb2 varb3 varb4 varb5 varb6 varb7             covb1b4 covb1b5 covb1b7 covb4b5 covb4b7 covb5b7;gen conb0=b1+b4*MV+b5*W0+b7*(MV*W0) if _n<220;gen conb1=b1+b4*MV+b5*W1+b7*(MV*W1) if _n<220;gen conb2=b1+b4*MV+b5*W2+b7*(MV*W2) if _n<220;gen conb3=b1+b4*MV+b5*W3+b7*(MV*W3) if _n<220;gen conse0=sqrt(varb1                + varb4*(MV^2) + varb5*(W0^2) + varb7*(MV^2)*(W0^2)                + 2*MV*covb1b4 + 2*W0*covb1b5 + 2*MV*W0*covb1b7 + 2*MV*W0*covb4b5                + 2*W0*(MV^2)*covb4b7 + 2*(W0^2)*MV*covb5b7) if _n<220;gen conse1=sqrt(varb1                + varb4*(MV^2) + varb5*(W1^2) + varb7*(MV^2)*(W1^2)                + 2*MV*covb1b4 + 2*W1*covb1b5 + 2*MV*W1*covb1b7 + 2*MV*W1*covb4b5                + 2*W1*(MV^2)*covb4b7 + 2*(W1^2)*MV*covb5b7) if _n<220;gen conse2=sqrt(varb1                + varb4*(MV^2) + varb5*(W2^2) + varb7*(MV^2)*(W2^2)                + 2*MV*covb1b4 + 2*W2*covb1b5 + 2*MV*W2*covb1b7 + 2*MV*W2*covb4b5                + 2*W2*(MV^2)*covb4b7 + 2*(W2^2)*MV*covb5b7) if _n<220;gen conse3=sqrt(varb1                + varb4*(MV^2) + varb5*(W3^2) + varb7*(MV^2)*(W3^2)                + 2*MV*covb1b4 + 2*W3*covb1b5 + 2*MV*W3*covb1b7 + 2*MV*W3*covb4b5                + 2*W3*(MV^2)*covb4b7 + 2*(W3^2)*MV*covb5b7) if _n<220;      gen t0=conb0/conse0;gen t1=conb1/conse1;gen t2=conb2/conse2;gen t3=conb3/conse3;gen consb0=conb0;gen consb1=conb1;gen consb2=conb2;gen consb3=conb3;replace consb0 = . if abs(t0)<1.96;replace consb1 = . if abs(t1)<1.96;replace consb2 = . if abs(t2)<1.96;replace consb3 = . if abs(t3)<1.96;generate str1 txt="*";

graph twoway   line conb0  MV,  clcolor(maroon) clpattern() clwidth(medthick)  /**/        ||  scatter consb0 MV, mlabel(txt) msymbol(i) mlabsize(vsmall) mlabgap(-1.0) mlabposition(11) /**/        ||     line conb1  MV,  clcolor(black) clpattern(dash) clwidth(medthick) /* */       ||  scatter consb1 MV,  mlabel(txt) msymbol(i) mlabsize(vsmall) mlabgap(-1.0) mlabposition(11)/*  */      ||     line conb2  MV,  clcolor(none)clpattern(dot) clwidth(medthick) /**/        ||  scatter consb2 MV,  mlabel() msymbol(i) mlabsize(vsmall) mlabgap(-1.0) mlabposition(11) /**/       ||     line conb3  MV,  clcolor(none) clpattern() clwidth() /**/        ||  scatter consb3 MV,  mlabel() msymbol(i) mlabsize(vsmall) mlabgap(-1.0) mlabposition(11)  /**/     graphregion(color(white))  /**/  ytitle(Marginal Effect of Change in Imports,size(3)) xtitle(Level of Import Openness (% GDP)) xlabel() yline(0, lcolor(black)) title("", size(3)) /**/  note(* = significance at 95%, size(2.5)) caption() /**/  title(Marginal effect of increasing imports on education spending (% Total Spending), size(2.75)) /*
*/  legend(off)

drop  MV conb0 conb1 conb2 conb3 conse0 conse1 conse2 conse3 t0 t1 t2 t3 consb0 consb1 consb2 consb3 txt


xi3:  xtpcse welfg_change importld*importlag*pdirvlag welfglag welfgld lngdpcapld lngdpcaplag /*
*/ dependld dependlag polity_di_revld exportgdplag exportgdpld /*
*/ bn_cab_xoka_gd_zslag bn_cab_xoka_gd_zsld  log_dt_dod_dect_cdlag log_dt_dod_dect_cdld   year f1-f215 if oecd==0, paestimates store welfg_poldirev
estimates restore welfg_poldirev#delimit ;generate MV=((_n-1)/1);replace  MV=. if _n>220;scalar W0 =      0;scalar W1=     1;scalar W2=     0;scalar W3=       1;matrix b=e(b);matrix V=e(V);scalar b1=b[1,1];scalar b2=b[1,2];scalar b3=b[1,3];scalar b4=b[1,4];scalar b5=b[1,5];scalar b6=b[1,6];scalar b7=b[1,7];scalar varb1=V[1,1];scalar varb2=V[2,2];scalar varb3=V[3,3];scalar varb4=V[4,4];scalar varb5=V[5,5];scalar varb6=V[6,6];scalar varb7=V[7,7];scalar covb1b4=V[1,4];scalar covb1b5=V[1,5];scalar covb1b7=V[1,7];scalar covb4b5=V[4,5];scalar covb4b7=V[4,7];scalar covb5b7=V[5,7];scalar list b1 b2 b3 b4 b5 b6 b7 varb1 varb2 varb3 varb4 varb5 varb6 varb7             covb1b4 covb1b5 covb1b7 covb4b5 covb4b7 covb5b7;gen conb0=b1+b4*MV+b5*W0+b7*(MV*W0) if _n<220;gen conb1=b1+b4*MV+b5*W1+b7*(MV*W1) if _n<220;gen conb2=b1+b4*MV+b5*W2+b7*(MV*W2) if _n<220;gen conb3=b1+b4*MV+b5*W3+b7*(MV*W3) if _n<220;gen conse0=sqrt(varb1                + varb4*(MV^2) + varb5*(W0^2) + varb7*(MV^2)*(W0^2)                + 2*MV*covb1b4 + 2*W0*covb1b5 + 2*MV*W0*covb1b7 + 2*MV*W0*covb4b5                + 2*W0*(MV^2)*covb4b7 + 2*(W0^2)*MV*covb5b7) if _n<220;gen conse1=sqrt(varb1                + varb4*(MV^2) + varb5*(W1^2) + varb7*(MV^2)*(W1^2)                + 2*MV*covb1b4 + 2*W1*covb1b5 + 2*MV*W1*covb1b7 + 2*MV*W1*covb4b5                + 2*W1*(MV^2)*covb4b7 + 2*(W1^2)*MV*covb5b7) if _n<220;gen conse2=sqrt(varb1                + varb4*(MV^2) + varb5*(W2^2) + varb7*(MV^2)*(W2^2)                + 2*MV*covb1b4 + 2*W2*covb1b5 + 2*MV*W2*covb1b7 + 2*MV*W2*covb4b5                + 2*W2*(MV^2)*covb4b7 + 2*(W2^2)*MV*covb5b7) if _n<220;gen conse3=sqrt(varb1                + varb4*(MV^2) + varb5*(W3^2) + varb7*(MV^2)*(W3^2)                + 2*MV*covb1b4 + 2*W3*covb1b5 + 2*MV*W3*covb1b7 + 2*MV*W3*covb4b5                + 2*W3*(MV^2)*covb4b7 + 2*(W3^2)*MV*covb5b7) if _n<220;      gen t0=conb0/conse0;gen t1=conb1/conse1;gen t2=conb2/conse2;gen t3=conb3/conse3;gen consb0=conb0;gen consb1=conb1;gen consb2=conb2;gen consb3=conb3;replace consb0 = . if abs(t0)<1.96;replace consb1 = . if abs(t1)<1.96;replace consb2 = . if abs(t2)<1.96;replace consb3 = . if abs(t3)<1.96;generate str1 txt="*";

graph twoway   line conb0  MV,  clcolor(maroon) clpattern() clwidth(medthick)  /**/        ||  scatter consb0 MV, mlabel(txt) msymbol(i) mlabsize(vsmall) mlabgap(-1.0) mlabposition(11) /**/        ||     line conb1  MV,  clcolor(black) clpattern(dash) clwidth(medthick) /* */       ||  scatter consb1 MV,  mlabel(txt) msymbol(i) mlabsize(vsmall) mlabgap(-1.0) mlabposition(11)/*  */      ||     line conb2  MV,  clcolor(none)clpattern(dot) clwidth(medthick) /**/        ||  scatter consb2 MV,  mlabel() msymbol(i) mlabsize(vsmall) mlabgap(-1.0) mlabposition(11) /**/       ||     line conb3  MV,  clcolor(none) clpattern() clwidth() /**/        ||  scatter consb3 MV,  mlabel() msymbol(i) mlabsize(vsmall) mlabgap(-1.0) mlabposition(11)  /**/     graphregion(color(white))  /**/  ytitle(Marginal Effect of Change in Imports,size(3)) xtitle(Level of Import Openness (% GDP)) xlabel() yline(0, lcolor(black)) title("", size(3)) /**/  note(* = significance at 95%, size(2.5)) caption() /**/  title(Marginal effect of increasing imports on welfare spending (% Total Spending), size(2.75)) /*
*/  legend(off)

drop  MV conb0 conb1 conb2 conb3 conse0 conse1 conse2 conse3 t0 t1 t2 t3 consb0 consb1 consb2 consb3 txt


estimates table educ_poldirev welfg_poldirev , /*
 */ b(%10.2f) se(%10.2f) p(%10.2f) stats(N) /*
 */ keep(importld importlag pdirvlag _IimXim _IimXpd _I1imXpd _IimXimXpd /*
 */ educlag educld welfglag welfgld exportgdplag exportgdpld lngdpcapld /*
 */ lngdpcaplag dependld dependlag polity_di_revld bn_cab_xoka_gd_zslag bn_cab_xoka_gd_zsld /*
 */ log_dt_dod_dect_cdlag log_dt_dod_dect_cdld year) label


